package push.totop.filenamechange

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Environment
import android.widget.ArrayAdapter
import android.widget.ListAdapter
import android.widget.ListView
import top.pushmy.MyTree
import java.io.File


class MainActivity : AppCompatActivity() {

    var myStrArr = mutableListOf<String>()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val fileNameListView = findViewById<ListView>(R.id.FileNameListView)
//        var f = Environment.getExternalStorageDirectory()
        var f  = Environment.getRootDirectory()

        var rootPath  = Environment.getRootDirectory().toString()

        var rootNode = MyTree<String>(rootPath,ArrayList<MyTree<String>>(),null)
        for(str in f.list()){
            rootNode.children?.add(MyTree(str, ArrayList<MyTree<String>>(),rootNode))
            println(str)
        }






        getDir(f)



        fileNameListView.adapter = MyAdapter(myStrArr,this)



    }

    private fun getDir(f: File) {
        myStrArr = f.list().toMutableList()
    }

//    private fun initFileData() {
//        getFiles()
//
//
//    }

}

